package chen.web.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import chen.web.cache.CacheInfo;
import chen.web.cache.CacheUtils;
import chen.web.controller.forum.JSONResponse;

@Controller
public class CacheController {
	
	
	@RequestMapping(value="/cache", method=RequestMethod.GET)
	public @ResponseBody JSONResponse allCatcheInfos(){
		AdminRoleVerify.verify();
		List<CacheInfo> list = CacheUtils.cacheInfo();
		return JSONResponse.successed(list);
	}
	
	@RequestMapping(value="/cache/clear", method=RequestMethod.POST)
	public @ResponseBody JSONResponse clear(@RequestParam String name){
		AdminRoleVerify.verify();
		CacheUtils.clear(name);
		return JSONResponse.successed();
	}
}
